local skel = fk.CreateSkill {
  name = "efengqi__jiewei",
}

Fk:loadTranslationTable{
  ["efengqi__jiewei"] = "解围",
  [":efengqi__jiewei"] = "若你武将牌背面朝上，你可以将装备牌当【无懈可击】使用，且翻至正面后摸三张牌。",

  ["#efengqi__jiewei-vs"] = "解围：你可以将装备牌当【无懈可击】使用",

  ["$efengqi__jiewei1"] = "以守为攻，伺机而动！",
  ["$efengqi__jiewei2"] = "援军已到，转守为攻！",
}

skel:addEffect("viewas", {
  anim_type = "control",
  audio_index = 1,
  pattern = "nullification",
  prompt = "#efengqi__jiewei-vs",
  handly_pile = true,
  card_filter = function (self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).type == Card.TypeEquip
  end,
  view_as = function(self, _, cards)
    if #cards ~= 1 then return nil end
    local c = Fk:cloneCard("nullification")
    c.skillName = skel.name
    c:addSubcard(cards[1])
    return c
  end,
  enabled_at_play = Util.FalseFunc,
  enabled_at_response = function (self, player, response)
    return not response and not player.faceup and
    (#player:getCardIds("e") > 0 or #player:getHandlyIds() > 0)
  end,
})

skel:addEffect(fk.TurnedOver, {
  anim_type = "drawcard",
  audio_index = 2,
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.faceup
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:drawCards(3, skel.name)
  end,
})

return skel
